﻿@using KRM.Core
@model KRM.Core.tblLoad

@{
    ViewBag.Title = "Add Image To Order";
    Layout = "~/Views/Shared/_popupLayout.cshtml";
}
<script>
    $(document).ready(function () {
        
    });
</script>
<script src="~/js/load.js"></script>
<div style="padding: 10px">
    <input type="hidden" id="SelectedImageId" value="" />
    <input type="hidden" id="SelectedOrderItemId" value="" />
    <input type="hidden" name ="FolderPath" id="FolderPath" value="@Server.UrlEncode(ViewBag.Folder)"/>
    <form style="display: none" method="POST" action="/Load/UploadLoadImages" id="frUploadfile" enctype="multipart/form-data">
        <input type="file" name="FileUpload" style="float: right" id="inputUploadfile" onchange="$('#frUploadfile').submit()" />
        <input type="hidden" name="loadid" value="@Model.LoadID"/>
    </form>
    <div class="row-fluid">
        <div class="span4">
            <fieldset>
                <legend>List Files</legend>
                <div class="row-fluid">
                    Load Code: @Model.LoadCode
                    <button type="button" class="btn btn-primary" style="float: right" onclick="$('#inputUploadfile').click()"><i class=" icon-plus"></i>Upload</button>

                    <div class="row-fluid">
                        <div class="span12" style="border: solid 1px gray; margin-top: 10px; height: 480px;overflow-y: auto" id="lstLoadImage">
                            @foreach (tblLoadItemPhoto item in ViewBag.ListLoadItemPhotos)
                            {
                                if (System.IO.File.Exists(item.PhotoSrc))
                                {
                                    <div data-id="@item.ID" class="loadimageitem" style="height:145px;width: 165px;float: left; margin:5px" >
                                    <div  style="border: solid 1px gainsboro; padding: 5px; @(item.isDriverManifests == true?"background: rgb(248, 248, 0)":"")">
                                        <div style="">
                                            @item.PhotoName
                                            <div class="btn-group" style="float: right;">
                                                <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><span class="caret"></span></a>
                                                <ul class="dropdown-menu">
                                                    <li>
                                                        <a href="#" onclick="AddImageToSelectedOrder(@item.ID)">Add To Selected Order</a>
                                                    </li>
                                                    <li>
                                                        <a href="#" onclick="DeleteLoadImage(@item.ID)">Remove Image From Load</a>
                                                    </li>
                                                    <li>
                                                        @if (item.isDriverManifests == true)
                                                        {
                                                            <a href="#" onclick=" SetImageIsDriverManifest(@item.ID,0)">Is Not Driver Manifest</a>
                                                        }
                                                        else
                                                        {
                                                            <a href="#" onclick=" SetImageIsDriverManifest(@item.ID,1) ">Is Driver Manifest</a>
                                                        }
                                                    </li>
                                                    <li>
                                                        <a target="_bank" href="/load/getfile?path=@item.PhotoSrc">View Photo</a>
                                                    </li>
                                                    <li>
                                                        <a target="_blank" href="/products/ProductInstructions?path=C:\KRMTestServer\//NF38911&amp;isShortCut=True">Open Folder</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                        <div style="height:100px; width: 150px;margin-top: 15px;">
                                              <img style="max-height:100px; max-width: 150px" src="/load/getfile?path=@Server.UrlEncode(item.PhotoSrc)" />
                                        </div>
                                    </div>
                                </div>
                                        @*<div data-id="@item.ID" class="loadimageitem"  style="text-align: center;height: 100px; width: 150px; float: left; margin: 5px; border: solid 1px gainsboro; padding: 5px" onclick=" $('#SelectedImageId').val(@item.ID) ">
                                            <img style="max-height: 100px; max-width: 150px" src="/load/getfile?path=@Server.UrlEncode(item.PhotoSrc)" />
                                        </div>*@
                                }
                            }
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
        <div class="span8">
            <div id="divViewLoadDetail">
                <div class="row-fluid">
                    <div class="fieldset" style="margin-top: 18px;">
                        <div class="legend"><span>List Order</span></div>
                        <div class="small-scroll" style="height: 300px">
                            <table class="table table-bordered table-fix tbl-selected" data-height="200">
                                <thead>
                                    <tr>
                                        <th>ItemStatusID
                                        </th>
                                        <th>OrderRef
                                        </th>
                                        <th>Postcode
                                        </th>
                                        <th>OrderItemID
                                        </th>
                                        <th>Qty
                                        </th>
                                        <th>Product
                                        </th>
                                        <th>SpecialInstructions
                                        </th>
                                        <th>WeightKG
                                        </th>
                                        <th>Packages
                                        </th>
                                        <th>Customer
                                        </th>
                                        <th>Address
                                        </th>
                                        <th>Telephone1
                                        </th>
                                        <th>Telephone2
                                        </th>
                                        <th>EmailAddress
                                        </th>
                                        <th>ProductID
                                        </th>
                                        <th>ProductOptionID
                                        </th>
                                        <th>DatePlaced
                                        </th>
                                        <th>WarehouseID
                                        </th>
                                        <th>carrierName
                                        </th>
                                        <th>carrierID
                                        </th>
                                        <th>DropID
                                        </th>
                                        <th>OrderID
                                        </th>
                                        <th>LoadID
                                        </th>
                                        <th>ItemCancelled
                                        </th>
                                        <th>DropNumber
                                        </th>
                                        <th>Mobile
                                        </th>
                                        <th>DeliveryDate
                                        </th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var item in ViewBag.SelectedLoadItems)
                                    {
                                        <tr onclick="$('#SelectedorderItemId').val('@item.OrderItemID');ViewLoadItemImages('@item.OrderItemID');">
                                            <td>
                                                @item.ItemStatusID
                                            </td>
                                            <td>
                                                @item.OrderRef
                                            </td>
                                            <td>
                                                @item.Postcode
                                            </td>
                                            <td>
                                                @item.OrderItemID
                                            </td>
                                            <td>
                                                @item.Qty
                                            </td>
                                            <td>
                                                @item.Product
                                            </td>
                                            <td>
                                                @item.SpecialInstructions
                                            </td>
                                            <td>
                                                @item.WeightKG
                                            </td>
                                            <td>
                                                @item.Packages
                                            </td>
                                            <td>
                                                @item.Customer
                                            </td>
                                            <td>
                                                @item.Address
                                            </td>
                                            <td>
                                                @item.Telephone1
                                            </td>
                                            <td>
                                                @item.Telephone2
                                            </td>
                                            <td>
                                                @item.EmailAddress
                                            </td>
                                            <td>
                                                @item.ProductID
                                            </td>
                                            <td>
                                                @item.ProductOptionID
                                            </td>
                                            <td>
                                                @item.DatePlaced
                                            </td>
                                            <td>
                                                @item.WarehouseID
                                            </td>
                                            <td>
                                                @item.carrierName
                                            </td>
                                            <td>
                                                @item.carrierID
                                            </td>
                                            <td>
                                                @item.DropID
                                            </td>
                                            <td>
                                                @item.OrderID
                                            </td>
                                            <td>
                                                @item.LoadID
                                            </td>
                                            <td>
                                                @item.ItemCancelled
                                            </td>
                                            <td>
                                                @item.DropNumber
                                            </td>
                                            <td>
                                                @item.Mobile
                                            </td>
                                            <td>
                                                @item.DeliveryDate
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="row-fluid">
                    <fieldset>
                        <legend>Images of order</legend>
                        <div id="lstOrderItemImages"></div>
                    </fieldset>
                </div>
            </div>
        </div>
    </div>
</div>
